package com.szdvte.news.filter;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

public class EncodingFilter implements Filter{
	private static String encode;
	private static String contentType;
	public void destroy() {
		
	}

	public void doFilter(ServletRequest request, ServletResponse response,
			FilterChain chian) throws IOException, ServletException {
		request.setCharacterEncoding(encode);
		response.setContentType(contentType);
		chian.doFilter(request, response);
	}

	public void init(FilterConfig filter) throws ServletException {
		encode=filter.getInitParameter("encode");
		contentType=filter.getInitParameter("contentType");
	}

}
